using QQZiFramework;
using QQZiFramework.Modals;
using System;
using System.Collections.Generic;
using System.DrawingCore;
using System.DrawingCore.Drawing2D;
using System.DrawingCore.Imaging;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using QQZiFramework.Membership;
using System.Collections;
using QRCoder;
using System.IO;
using System.Collections.Specialized;
using System.Xml;

namespace QQZiFramework
{
    public static class UtilityExtension
    {
        

        /// <summary>
        /// 获取Json的配置值，path以:隔开
        /// </summary>
        public static bool TryGetValue<T>(this Newtonsoft.Json.Linq.JToken token ,string path, out T t)
        {
            if (token == null)
            {
                t = default(T);
                return false;
            }
            string[] pathArr = path.Split(':');
            for (int i = 0; i < pathArr.Length; i++)
            {
                token = token[pathArr[i]];
                if (token == null) { 
                    break;
                }; 
                if (!token.HasValues )
                {
                    if( i!= pathArr.Length -1) token = null;
                    break;
                }
               
            }
            if (token == null)
            {
                t = default(T);
                return false;
            }
            else
            {
                t = token.ToObject<T>();
                return true;
            }

        }



    }
}
